﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using BobDotNet.Classes.Base;

namespace BobDotNet.Classes.Dao
{
    class DaoProprieteAchat
    {
        public static ProprieteAchat Charge(string id)
        {
            return DaoProprieteAchat.Charge(Int32.Parse(id));
        }

        public static ProprieteAchat Charge(Int32 id)
        {
            return (ProprieteAchat)DaoBase.Charge(id, ProprieteAchat.NomClasse);
        }

        public static List<ProprieteAchat> ChargeTout()
        {
            List<ProprieteAchat> retour;
            ISession session = NHibernateSessionManager.Instance.GetSession();
            retour = (List<ProprieteAchat>)session.CreateCriteria(typeof(ProprieteAchat)).List<ProprieteAchat>();
            NHibernateSessionManager.Instance.CloseSession();
            return retour;
        }

        public static void MettreAJour(ProprieteAchat u)
        {
            try
            {
                DaoBase.MettreAJour(u);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void Creer(ProprieteAchat u)
        {
            try
            {
                DaoBase.Creer(u);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void Supprimer(string Id)
        {
            DaoProprieteAchat.Supprimer(Int32.Parse(Id));
        }

        public static void Supprimer(Int32 Id)
        {
            DaoProprieteAchat.Supprimer(DaoProprieteAchat.Charge(Id));
        }

        public static void Supprimer(ProprieteAchat u)
        {
            try
            {
                DaoBase.Supprimer(u);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}